<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    
<%@ page import="com.tenpay.MediPayRequestHandler"%>
<%@ page import="com.tenpay.util.TenpayUtil" %> 
<%@ page import="com.mrent.entity.Tenpay" %>     
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>财付通支付</title>
</head>
<body>
<%
Tenpay tenpay = (Tenpay)request.getAttribute("tenpay");
//平台商密钥
String key = tenpay.getKey();

//平台商帐号
String chnid = tenpay.getChnid();

//卖家
String seller = tenpay.getSeller();

//回调通知URL
String mch_returl = tenpay.getMch_returl();

//支付显示URL
String show_url = tenpay.getShow_url();

//商家订单号
String mch_vno = tenpay.getMch_vno();

//创建MediPayRequestHandler实例
MediPayRequestHandler reqHandler = new MediPayRequestHandler(request, response);

//设置密钥
reqHandler.setKey(key);

//初始化
reqHandler.init();

//-----------------------------
//设置支付参数
//-----------------------------
reqHandler.setParameter("chnid", chnid);											//平台商帐号
reqHandler.setParameter("encode_type", tenpay.getEncode_type());					//编码类型 1:gbk 2:utf-8
reqHandler.setParameter("mch_desc", tenpay.getMch_desc());							//交易说明
reqHandler.setParameter("mch_name", tenpay.getMch_name());							//商品名称
reqHandler.setParameter("mch_price", tenpay.getMch_price()); 						//商品总价，单位为分
reqHandler.setParameter("mch_returl", mch_returl); 									//回调通知URL
reqHandler.setParameter("mch_type", tenpay.getMch_type());							//交易类型：1、实物交易，2、虚拟交易
reqHandler.setParameter("mch_vno", mch_vno);										//商家的定单号
reqHandler.setParameter("need_buyerinfo", tenpay.getNeed_buyerinfo());				//是否需要在财付通填定物流信息，1：需要，2：不需要。
reqHandler.setParameter("seller", seller);											//卖家财付通帐号
reqHandler.setParameter("show_url", show_url);										//支付后的商户支付结果展示页面
reqHandler.setParameter("transport_desc", tenpay.getTransport_desc());				//物流公司或物流方式说明
reqHandler.setParameter("transport_fee", tenpay.getTransport_fee());				//需买方另支付的物流费用

//获取请求带参数的url
String requestUrl = reqHandler.getRequestURL();

//获取debug信息
String debuginfo = reqHandler.getDebugInfo();

System.out.println("requestUrl:" + requestUrl);
System.out.println("debuginfo:" + debuginfo);
reqHandler.doSend();
%>
</body>
</html>